<%@page import="java.lang.Integer"%>
<%@page import="java.util.Hashtable"%>
<%@page import="java.util.List"%>
<%@page import="com.qmerak.common.DataBaseUtil"%>
<%@page import="com.qmerak.common.SpringUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../css/style_01.css" rel="stylesheet" type="text/css" />
<title>Insert title here</title>
</head>
<body class="nr_bg">
	<table width="100%" height="45" border="0" align="center"
		cellpadding="0" cellspacing="0">
		<tr>
			<td width="88%" align="center" class="test_bt">工会会员信息统计报表</td>
		</tr>
	</table>
	<table width="100%" border="0" cellspacing="1" cellpadding="1">
		<thead>
			<tr class="tr">
				<td class="V_info_type" align="center"></td>
				<td class="V_info_type" align="center" nowrap="nowrap" colspan="2">性别</td>
				<td class="V_info_type" align="center" nowrap="nowrap" colspan="4">年龄</td>
				<td class="V_info_type" align="center" nowrap="nowrap" colspan="4">政治面貌</td>
				<td class="V_info_type" align="center" nowrap="nowrap" colspan="5">学历</td>
				<td class="V_info_type" align="center" nowrap="nowrap" colspan="3">用工形式</td>
				<td class="V_info_type" align="center" nowrap="nowrap" colspan="3">职称</td>
			</tr>
			<tr class="tr">
				<td class="V_info_type" align="center"></td>
				<td class="V_info_type" align="center" nowrap="nowrap">男</td>
				<td class="V_info_type" align="center" nowrap="nowrap">女</td>
				<td class="V_info_type" align="center" nowrap="nowrap">30以下</td>
				<td class="V_info_type" align="center" nowrap="nowrap">30-40</td>
				<td class="V_info_type" align="center" nowrap="nowrap">40-50</td>
				<td class="V_info_type" align="center" nowrap="nowrap">50-60</td>
				<td class="V_info_type" align="center" nowrap="nowrap">中共党员</td>
				<td class="V_info_type" align="center" nowrap="nowrap">共青团员</td>
				<td class="V_info_type" align="center" nowrap="nowrap">民主党派</td>
				<td class="V_info_type" align="center" nowrap="nowrap">群众</td>
				<td class="V_info_type" align="center" nowrap="nowrap">大专以下</td>
				<td class="V_info_type" align="center" nowrap="nowrap">大专</td>
				<td class="V_info_type" align="center" nowrap="nowrap">本科</td>
				<td class="V_info_type" align="center" nowrap="nowrap">硕士</td>
				<td class="V_info_type" align="center" nowrap="nowrap">博士</td>
				<td class="V_info_type" align="center" nowrap="nowrap">合同A</td>
				<td class="V_info_type" align="center" nowrap="nowrap">合同B</td>
				<td class="V_info_type" align="center" nowrap="nowrap">临时</td>
				<td class="V_info_type" align="center" nowrap="nowrap">高级</td>
				<td class="V_info_type" align="center" nowrap="nowrap">中级</td>
				<td class="V_info_type" align="center" nowrap="nowrap">初级</td>
			</tr>
		</thead>
		<tbody>
			<tr class="tr_sub" align="center">
				<td class="V_info_type" nowrap="nowrap">全省总计</td>
				<%
					String sql = "select sexual groupname,count(*) num from t_member group by sexual";
					List<Hashtable<String, Object>> datas = DataBaseUtil.query(sql);
					Hashtable<String, Object> table = new Hashtable<String, Object>();
					for (Hashtable<String, Object> data : datas) {
						table.put(String.valueOf(data.get("groupname")),
								data.get("num"));
					}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("1"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("2"))%></td>
				<%
					sql = "select count(*) num from t_member where birthday>'"
							+ DataBaseUtil.ageToDate(30, "yyyy-mm-dd") + "'";
					datas = DataBaseUtil.query(sql);
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(datas.get(0).get("num"))%></td>
				<%
					sql = "select count(*) num from t_member where birthday<'"
							+ DataBaseUtil.ageToDate(30, "yyyy-mm-dd")
							+ "' and birthday>'"
							+ DataBaseUtil.ageToDate(40, "yyyy-mm-dd") + "'";
					datas = DataBaseUtil.query(sql);
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(datas.get(0).get("num"))%></td>
				<%
					sql = "select count(*) num from t_member where birthday<'"
							+ DataBaseUtil.ageToDate(40, "yyyy-mm-dd")
							+ "' and birthday>'"
							+ DataBaseUtil.ageToDate(50, "yyyy-mm-dd") + "'";
					datas = DataBaseUtil.query(sql);
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(datas.get(0).get("num"))%></td>
				<%
					sql = "select count(*) num from t_member where birthday<'"
							+ DataBaseUtil.ageToDate(50, "yyyy-mm-dd")
							+ "' and birthday>'"
							+ DataBaseUtil.ageToDate(60, "yyyy-mm-dd") + "'";
					datas = DataBaseUtil.query(sql);
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(datas.get(0).get("num"))%></td>
				<%
					sql = "select political groupname,count(*) num from t_member group by political";
					datas = DataBaseUtil.query(sql);
					table.clear();
					for (Hashtable<String, Object> data : datas) {
						table.put(String.valueOf(data.get("groupname")),
								data.get("num"));
					}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("01"), table.get("02"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("03"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("04"), table.get("05"),
					table.get("06"), table.get("07"), table.get("08"),
					table.get("09"), table.get("10"), table.get("11"),
					table.get("12"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("13"))%></td>
				<%
					sql = "select educational groupname,count(*) num from t_member group by educational";
					datas = DataBaseUtil.query(sql);
					table.clear();
					for (Hashtable<String, Object> data : datas) {
						table.put(String.valueOf(data.get("groupname")),
								data.get("num"));
					}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("50"), table.get("60"),
					table.get("70"), table.get("80"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("40"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("30"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("20"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("10"))%></td>
				<%
					sql = "select employ_mode groupname,count(*) num from t_member group by employ_mode";
					datas = DataBaseUtil.query(sql);
					table.clear();
					for (Hashtable<String, Object> data : datas) {
						table.put(String.valueOf(data.get("groupname")),
								data.get("num"));
					}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("01"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("02"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("03"))%></td>
				<%
					sql = "select position groupname,count(*) num from t_member group by position";
					datas = DataBaseUtil.query(sql);
					table.clear();
					for (Hashtable<String, Object> data : datas) {
						table.put(String.valueOf(data.get("groupname")),
								data.get("num"));
					}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("01"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("02"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("03"))%></td>
			</tr>
			<%
				sql = "select id,union_name name from t_org";
				List<Hashtable<String, Object>> unions = DataBaseUtil.query(sql);
				for (Hashtable<String, Object> union : unions) {
			%>
			<tr align="center">
				<td class="V_info_type" nowrap="nowrap"><%=union.get("name")%></td>
				<%
					sql = "select sexual groupname,count(*) num from t_member where work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "') group by sexual";
						datas = DataBaseUtil.query(sql);
						table.clear();
						for (Hashtable<String, Object> data : datas) {
							table.put(String.valueOf(data.get("groupname")),
									data.get("num"));
						}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("1"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("2"))%></td>
				<%
					sql = "select count(*) num from t_member where birthday>'"
								+ DataBaseUtil.ageToDate(30, "yyyy-mm-dd")
								+ "' and work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "')";
						datas = DataBaseUtil.query(sql);
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(datas.get(0).get("num"))%></td>
				<%
					sql = "select count(*) num from t_member where birthday<'"
								+ DataBaseUtil.ageToDate(30, "yyyy-mm-dd")
								+ "' and birthday>'"
								+ DataBaseUtil.ageToDate(40, "yyyy-mm-dd")
								+ "' and work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "')";
						datas = DataBaseUtil.query(sql);
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(datas.get(0).get("num"))%></td>
				<%
					sql = "select count(*) num from t_member where birthday<'"
								+ DataBaseUtil.ageToDate(40, "yyyy-mm-dd")
								+ "' and birthday>'"
								+ DataBaseUtil.ageToDate(50, "yyyy-mm-dd")
								+ "' and work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "')";
						datas = DataBaseUtil.query(sql);
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(datas.get(0).get("num"))%></td>
				<%
					sql = "select count(*) num from t_member where birthday<'"
								+ DataBaseUtil.ageToDate(50, "yyyy-mm-dd")
								+ "' and birthday>'"
								+ DataBaseUtil.ageToDate(60, "yyyy-mm-dd")
								+ "' and work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "')";
						datas = DataBaseUtil.query(sql);
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(datas.get(0).get("num"))%></td>
				<%
					sql = "select political groupname,count(*) num from t_member where work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "') group by political";
						datas = DataBaseUtil.query(sql);
						table.clear();
						for (Hashtable<String, Object> data : datas) {
							table.put(String.valueOf(data.get("groupname")),
									data.get("num"));
						}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("01"), table.get("02"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("03"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("04"), table.get("05"),
						table.get("06"), table.get("07"), table.get("08"),
						table.get("09"), table.get("10"), table.get("11"),
						table.get("12"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("13"))%></td>
				<%
					sql = "select educational groupname,count(*) num from t_member  where work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "') group by educational";
						datas = DataBaseUtil.query(sql);
						table.clear();
						for (Hashtable<String, Object> data : datas) {
							table.put(String.valueOf(data.get("groupname")),
									data.get("num"));
						}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("50"), table.get("60"),
						table.get("70"), table.get("80"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("40"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("30"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("20"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("10"))%></td>
				<%
					sql = "select employ_mode groupname,count(*) num from t_member where work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "') group by employ_mode";
						datas = DataBaseUtil.query(sql);
						table.clear();
						for (Hashtable<String, Object> data : datas) {
							table.put(String.valueOf(data.get("groupname")),
									data.get("num"));
						}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("01"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("02"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("03"))%></td>
				<%
					sql = "select position groupname,count(*) num from t_member where work_unit in (select id from t_unit where unionId='"
								+ union.get("id") + "') group by position";
						datas = DataBaseUtil.query(sql);
						table.clear();
						for (Hashtable<String, Object> data : datas) {
							table.put(String.valueOf(data.get("groupname")),
									data.get("num"));
						}
				%>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("01"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("02"))%></td>
				<td class="V_info_type" nowrap="nowrap"><%=DataBaseUtil.sum(table.get("03"))%></td>
			</tr>
			<%
				}
			%>
		</tbody>
	</table>
</body>
</html>